package com.community.owner.controller;

import com.community.common.core.controller.BaseController;
import com.community.common.core.page.TableDataInfo;
import com.community.owner.domain.OwnerPersonnelRecord;
import com.community.owner.domain.OwnerVehicleRecord;
import com.community.owner.domain.enums.SmartCode;
import com.community.owner.domain.vo.PersonnelRecordQuery;
import com.community.owner.service.OwnerPersonnelRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/ownerPersonnelRecord")
public class OwnerPersonnelRecordController extends BaseController {

    @Autowired
    private OwnerPersonnelRecordService personnelRecordService;

    //查询所有人员出入记录
    @RequestMapping("/selectPersonnelRecordList")
    public TableDataInfo selectPersonnelRecordList(PersonnelRecordQuery query) {
        try {
            startPage();  // 若依分页方法
            List<OwnerPersonnelRecord> ownerPersonnelRecords = personnelRecordService.selectPersonnelRecordList(query);
            // 添加调试信息
            logger.info("查询参数: {}", query);
            return getDataTable(ownerPersonnelRecords);  // 返回分页数据
        } catch (Exception e) {
            logger.error(SmartCode.Personnel_Record_Fail.getMsg());
            logger.error("人员记录失败详细错误:", e);
            return getDataTable(new ArrayList<>());  // 返回空的分页数据
        }
    }

}
